<script>
export default {
  data() {
    return {
      tableData: [],
      alibean:{
        name:""
      },
      requestparam:{
        pageNum:1,
        pageSize:10,
      },
      // checkCode:""
      }
    },
  methods:{
    handleSizeChange(val){
      this.requestparam.pageSize=val;
      this.initData();
    },
    handleCurrentChange(val){
      this.requestparam.pageNum=val;
      this.initData();
    },
    // 查询还款明细
    initData(){
      this.axios.post(`repay/repay/repaymentDetailsList?checkCode=${this.$route.params.checkCode}`,this.requestparam).then(res => {
        if (res.data.code == 200) {
          this.tableData = res.data.data;
        }
      })
    },
  //   还款
    // 还款页面
    pay(row){
      this.axios.post(`repay/repay/add?id=${row.id}`).then(res=>{
        if (res.data.code==200){
          // console.log(res.data.data.outTradeNo)
          // console.log(res.data.data.name)
          // console.log(res.data.data.repaymentPrice)
          this.$router.push({name:"Pay",params:{carName:row.carName,outTradeNo:res.data.data.outTradeNo,price:row.price}})
        }
      })
    } ,
    //进入个人信息页面
    toUser(){
      this.$router.push("/personaldetails")
    },
    //进入申请贷款页面
    toRepayment(){
      this.$router.push("/addrepayment")
    },
    //进入审核页面
    toShen(){
      this.$router.push("/check")
    },
    //进入车辆信息页面
    toCar(){
      this.$router.push('/loanshome')
    },

  },
  created() {
    this.initData();
   // this.checkCode=this.$route.params.checkCode;
    console.log(this.checkCode)

    // 获取数据
    const data = JSON.parse(localStorage.getItem('user'));
    //赋值然后显示登陆人
    this.user = data

  }
}
</script>

<template>
  <div id="home">
    <div id="daohang">
      <el-image
          style="width: 100px; height: 100px;margin-top: 50px"
          :src="this.user.pic"
      ></el-image>
      <h2 style="color: azure">欢迎您 {{user.username}}</h2>

      <el-col :span="12" style="width: 100%;height: 500px;">
        <el-menu
            default-active="3"
            class="el-menu-vertical-demo"
            background-color="#2c3e50"
            text-color="#fff"
            active-text-color="#ffd04b"
            style="border-right: #2c3e50">
          <el-menu-item index="1" @click="toCar()" style="width: 100%;float:left;">
            <i class="el-icon-menu" ></i>
            <span slot="title">车辆信息</span>
          </el-menu-item>
          <el-menu-item index="2" @click="toUser()" style="width: 100%;float:left;">
            <i class="el-icon-menu"></i>
            <span slot="title">个人信息</span>
          </el-menu-item>
          <el-menu-item index="3" style="width: 100%;float:left;">
            <i class="el-icon-menu"></i>
            <span slot="title">还款信息</span>
          </el-menu-item>
          <el-menu-item index="4" @click="toShen()" v-show="this.user.roleCode==4 || this.user.roleCode==5 || this.user.roleCode==6" style="width: 100%;float:left;">
            <i class="el-icon-menu"></i>
            <span slot="title">审核模块</span>
          </el-menu-item>
          <el-menu-item index="5" style="width: 100%;float:left;">
            <i class="el-icon-setting"></i>
            <span slot="title">系统设置</span>
          </el-menu-item>
        </el-menu>
      </el-col>
    </div>
    <div id="addP">
  <el-table
      :data="tableData.data"
      style="width: 100%">

    <el-table-column
        prop="carName"
        label="贷款产品名称">
    </el-table-column>
    <el-table-column
        prop="price"
        label="每月还款金额">
    </el-table-column>
    <el-table-column
        prop="time"
        label="还款日期">
    </el-table-column>
    <el-table-column
        prop="repaymentDate"
        label="实际还款时间">
    </el-table-column>
    <el-table-column
        prop="type"
        label="期数">
      <template slot-scope="scope">
        第{{scope.row.type}}期
      </template>
    </el-table-column>
    <el-table-column
        prop="repayStatus"
        label="还款状态">
      <template slot-scope="scope">
        {{scope.row.repayStatus==0?'已还款':'待还款'}}
      </template>
    </el-table-column>

    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
            size="mini"
            v-show="scope.row.repayStatus==1"
            @click="pay(scope.row)">还款</el-button>
      </template>
    </el-table-column>
  </el-table>

  <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="requestparam.pageNum"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="requestparam.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="tableData.total">
  </el-pagination>
    </div>
  </div>
</template>

<style>

#home{
  width: 100%;
  height: 815px;
  background-color: rgba(152, 134, 134, 0.18);
  box-sizing: border-box;
}



#daohang{
  width: 18%;
  height: 97%;
  background-color: #2c3e50;
  margin-left: 12px;
  margin-top: 10px;
  float: left;
  box-shadow: 3px 3px 3px 3px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
}
#addP{
  width: 79%;
  height:  97%;
  margin-top: 10px;
  margin-right: 12px;
  float: right;
  background-color: rgb(255, 255, 255);
  box-shadow: 3px 3px 3px 3px rgba(0, 0, 0, 0.2);
  padding: 15px;
  box-sizing: border-box;
}
</style>
